// import { createRouter, createWebHistory } from 'vue-router';
import { createRouter, createWebHashHistory } from 'vue-router';
import NProgress from 'nprogress'; // progress bar
import 'nprogress/nprogress.css';

// import { REDIRECT_MAIN, NOT_FOUND_ROUTE } from '@/router/routes/base';
// import appRoutes from './routes'; // export default appRoutes; 只有一个export时候
import { appRoutes } from './routes';
// import { REDIRECT_MAIN, NOT_FOUND_ROUTE } from './routes/base';
import createRouteGuard from './guard';

NProgress.configure({ showSpinner: false }); // NProgress Configuration

const router = createRouter({
  // history: createWebHistory(),  // 去掉url中的#号，需要服务器支持
  history: createWebHashHistory(),
  routes: [
    {
      path: '/',
      redirect: 'login',
    },
    // {
    //   path: '/',
    //   name: 'dashboard',
    //   component: () => import('@/views/dashboard/index.vue'),
    //   meta: {
    //     locale: 'menu.dashboard',
    //     requiresAuth: true,
    //     roles: ['*'],
    //   },
    // },
    {
      path: '/login',
      name: 'login',
      component: () => import('@/views/login/index.vue'),
      meta: {
        requiresAuth: false,
      },
    },
    ...appRoutes,
    {
      path: '/:pathMatch(.*)*',
      name: 'notFound',
      component: () => import('@/views/not-found/index.vue'),
    },
    // REDIRECT_MAIN, // 报错
    // NOT_FOUND_ROUTE,
  ],
  scrollBehavior() {
    return { top: 0 };
  },
});

createRouteGuard(router);

export default router;
